<#assign pagePkg=""/>
<#assign pageClsName=""/>
<#if style == 'pl-web'>
    <#assign pageClsName= "AbstractPage"/>
    <#assign pagePkg= "import com.pl.data.core.entity.dto.AbstractPage;"/>
<#elseif style == 'mybatis-plus'>
    <#assign pageClsName= "Page"/>
    <#assign pagePkg= "import com.baomidou.mybatisplus.extension.plugins.pagination.Page;"/>
</#if>
package ${packageName}.controller;

<#if model.wired>
import ${packageName}.service.${model.firstUpperCaseName}Service;
</#if>
<#if swagger>
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
</#if>
<#if model.basicApi>
import ${packageName}.dto.${model.firstUpperCaseName}Dto;
import ${model.responsePackageName};
${pagePkg}
</#if>
<#if model.importPackages??>
    <#list model.importPackages as pkg>
import ${pkg};
    </#list>

</#if>
/**
* @ClasssName ${model.firstUpperCaseName}Controller
* @Description ${model.comment}Controller
* @Author ${author}
* @Date ${date}
* @Version V1.0
*/
<#if model.annotations??>

    <#list model.annotations as annotation>
${annotation.name}${vmTools.buildAnnotayionProperties(annotation.properties)}
    </#list>
</#if>
<#if model.basicApi && style != 'mybatis'>
@Api(value = "${path}", tags = "${model.comment}API接口")
</#if>
public class ${model.firstUpperCaseName}Controller {
<#if model.wired>
    <#if model.wiredType == 'resource'>

    @Resource
    private ${model.firstUpperCaseName}Service ${model.firstLowerCaseName}Service;
    </#if>
    <#if model.wiredType == 'autoWired'>

    @AutoWired
    private ${model.firstUpperCaseName}Service ${model.firstLowerCaseName}Service;
    </#if>
    <#if model.wiredType == 'constructor'>

    private final ${model.firstUpperCaseName}Service ${model.firstLowerCaseName}Service;

    public ${model.firstUpperCaseName}Controller(${model.firstUpperCaseName}Service ${model.firstLowerCaseName}Service) {
        this.${model.firstLowerCaseName}Service = ${model.firstLowerCaseName}Service;
    }
    </#if>
    <#--<#if model.basicApi && style != 'mybatis'>-->
    <#if model.basicApi>

    /**
     * 分页列表查询
     *
     * @param ${model.firstLowerCaseName}Dto ${model.comment}
     * @return
     */
    <#if swagger>
    @ApiOperation(value = "分页列表查询${model.comment}", notes = "分页列表查询${model.comment}", httpMethod = "POST")
    </#if>
    @PostMapping("/pagelist/v1.0" )
    public ${model.responseClassName} get${model.firstUpperCaseName}List(@RequestBody ${model.firstUpperCaseName}Dto ${model.firstLowerCaseName}Dto, HttpServletRequest request) {
        ParamValidateUtil.checkEssentialParams(${model.firstLowerCaseName}Dto, "projectCode", "pageNum", "pageSize");
        return ${model.firstLowerCaseName}Service.pagelist(${model.firstLowerCaseName}Dto).setRequestInfo(${model.firstLowerCaseName}Dto);
    }

    /**
     * 新增
     *
     * @param ${model.firstLowerCaseName}Dto ${model.comment}
     * @return
     */
    <#if swagger>
    @ApiOperation(value = "新增${model.comment}", notes = "新增${model.comment}", httpMethod = "POST")
    </#if>
    @PostMapping("/add/v1.0")
    public ${model.responseClassName} add(@RequestBody ${model.firstUpperCaseName}Dto ${model.firstLowerCaseName}Dto, HttpServletRequest request) {
        ParamValidateUtil.checkEssentialParams(${model.firstLowerCaseName}Dto, "projectCode");
        return ${model.firstLowerCaseName}Service.save(${model.firstLowerCaseName}Dto).setRequestInfo(${model.firstLowerCaseName}Dto);
    }

    /**
     * 删除${model.comment}
     *
     * @param ${model.firstLowerCaseName}Dto ${model.comment}
     * @return
     */
    <#if swagger>
    @ApiOperation(value = "通过id删除${model.comment}", notes = "通过id删除${model.comment}", httpMethod = "POST")
    </#if>
    @PostMapping("/deleteById/v1.0")
    public ${model.responseClassName} delete(@RequestBody ${model.firstUpperCaseName}Dto ${model.firstLowerCaseName}Dto, HttpServletRequest request) {
        ParamValidateUtil.checkEssentialParams(${model.firstLowerCaseName}Dto, "projectCode");
        return ${model.firstLowerCaseName}Service.removeById(${model.firstLowerCaseName}Dto).setRequestInfo(${model.firstLowerCaseName}Dto);
    }

    /**
     * 修改${model.comment}
     *
     * @param ${model.firstLowerCaseName}Dto ${model.comment}
     * @return
     */
    <#if swagger>
    @ApiOperation(value = "修改${model.comment}", notes = "修改${model.comment}", httpMethod = "POST")
    </#if>
    @PostMapping("/updateById/v1.0")
    public ${model.responseClassName} update(@RequestBody ${model.firstUpperCaseName}Dto ${model.firstLowerCaseName}Dto, HttpServletRequest request) {
        ParamValidateUtil.checkEssentialParams(${model.firstLowerCaseName}Dto, "projectCode");
        return ${model.firstLowerCaseName}Service.updateById(${model.firstLowerCaseName}Dto).setRequestInfo(${model.firstLowerCaseName}Dto);
    }

    /**
     * 通过id查询${model.comment}
     * @param ${model.firstLowerCaseName}Dto ${model.comment}
     * @return
     */
    <#if swagger>
    @ApiOperation(value = "通过id查询${model.comment}", notes = "通过id查询${model.comment}", httpMethod = "POST")
    </#if>
    @PostMapping("/getById/v1.0")
    public ${model.responseClassName} getById(@RequestBody ${model.firstUpperCaseName}Dto ${model.firstLowerCaseName}Dto, HttpServletRequest request) {
        ParamValidateUtil.checkEssentialParams(${model.firstLowerCaseName}Dto, "projectCode");
        return ${model.firstLowerCaseName}Service.getById(${model.firstLowerCaseName}Dto).setRequestInfo(${model.firstLowerCaseName}Dto);
    }

    </#if>
</#if>

}
